package mysql

import "log"

type TextInfoDO struct {
	Code          string             `json:"code"`
	Type          int                `json:"type"`
	Name          string             `json:"name"`
	System        string             `json:"system"`
	LanguageDOMap map[string]LangeDO `json:"languageDOMap"`
}

type LangeDO struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type TransLgeTextDO struct {
	TransCode string `db:"trans_code"`
	LgeCode   string `db:"language_code"`
	Text      string `db:"text"`
}

type TransLgeTextMapper struct {
	Db *DataMysqlSourceClinet
}

func NewTransLgeTextMapper(DB *DataMysqlSourceClinet) (*TransLgeTextMapper) {
	mapper := &TransLgeTextMapper{}
	mapper.Db = DB
	return mapper
}

func (trs *TransLgeTextMapper) QueryAll() ([]TransLgeTextDO, error) {
	var translge []TransLgeTextDO
	e := trs.Db.SqlDB.Select(&translge,
		"select trans_code,language_code,text from trans_language_text "+
			"where deleted = 0 limit 2000")
	if e != nil {
		log.Println("查询失败！", e)
		return nil, e
	}

	if len(translge) == 0 {
		log.Println("数据为空")
		return nil, nil
	}
	return translge, nil
}
